package Day2025_03_25;

import java.util.Scanner;

public class Demo03 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt(), n = in.nextInt();
        in.nextLine();
        char[][] s = new char[m][n];
        for (int i = 0; i < m; i++) {
            String ss = in.nextLine();
            for (int j = 0; j < n; j++) {
                s[i][j] = ss.charAt(j);
            }
        }
        int[][] dp = new int[m + 1][n + 1];
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                int tmp = 0;
                if (s[i - 1][j - 1] == 'l') tmp = 4;
                else if (s[i - 1][j - 1] == 'o') tmp = 3;
                else if (s[i - 1][j - 1] == 'v') tmp = 2;
                else if (s[i - 1][j - 1] == 'e') tmp = 1;
                else tmp = 0;
                dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + tmp;
            }
        }
        System.out.println(dp[m][n]);
    }
}
